{{define "api/syncpriv.html"}}
<!DOCTYPE html>
<html lang="en">
{{template "common/header.html" .}}
<body>
    <div id="wrapper" class="container">
        {{template "common/navbar.html" .}}
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-8">
                    <h1 class="page-header">权限同步</h1>
                </div>
                <!-- /.col-lg-12 -->
                <div class="col-lg-4">
                    <div>
                        <div id="alert-success" class="alert alert-success fade in hidden">
                            <a href="#" class="close" data-dismiss="alert">&times;</a>
                            <strong class="title">Success!</strong>
                            <span class="message">Your message has been sent successfully.</span>
                        </div>
                    </div>
                    <div>
                        <div id="alert-error" class="alert alert-danger fade in hidden">
                            <a href="#" class="close" data-dismiss="alert">&times;</a>
                            <strong class="title">Error!</strong>
                            <span class="message">Your message has been sent Error.</span>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            权限同步:
                            <span>
                                <button type="button" class="btn btn-primary" id="sync_priv">Sync</button>
                            </span>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                
                            </div>
                            <!-- /.table-responsive -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
        </div>
        <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->
    {{template "common/footer.html" .}}

    <script>
        $(document).ready(function() {
            var url = "/admin/api/syncpriv"
            $("#sync_priv").bind("click", function(){
                if (window.confirm("Are you sure you want to Sync Datatbase Privilege to EPG Proxy?")) {
                    $.post(url,function(result, status){
                        if (status != "success"){
                            $("#alert-error .message").text("查询失败,code:"+ status);
                            $("#alert-error").removeClass("hidden").addClass("show");
                            return
                        }
                        console.log(result,status)
                        $(".dataTable_wrapper").html('<table width="100%" class="display" id="dt-sync_priv"></table>');
                        $("#dt-sync_priv").dataTable({
                            "columns":[{"title":"Host"},{"title":"Status"},{"title":"SyncTime"},{"title":"Message"}],
                            "data":result,
                        });
                    });
                }
            });
        });
    </script>
</body>

</html>
{{end}}